<template>  
    <view class="container">  
		<view class="user-section">
			<image class="bg" :src="img1" @click="navTo('/pages/usercenter/usercenter')" mode="aspectFill"></image>
			<view class="user-info-box">
				<view class="portrait-box">
					<!-- #ifdef MP-WEIXIN -->
					<image class="portrait" :src="avator || '/static/missing-face.png'" mode="aspectFill" ></image>
					<!-- #endif -->
					<!-- #ifndef MP-WEIXIN -->
					<image class="portrait" :src="avator || '/static/missing-face.png'" mode="aspectFill"  @click="navTo('/pages/usercenter/usercenter')"></image>
					<!-- #endif -->
				</view>
				<view class="info-box">
					<!-- #ifdef MP-WEIXIN -->
					<text class="username" v-if="NAME"  @click="navTo('/pages/usercenter/usercenter')">{{NAME}}</text>
					<button v-else style="background-color: transparent;font-size: 50upx;" type='default' open-type="getUserInfo" withCredentials="true" lang="zh_CN" @getuserinfo="wxGetUserInfo">
					    登录
					</button>
					<!-- #endif -->
					<!-- #ifndef MP-WEIXIN -->
					<text class="username"  @click="navTo('/pages/usercenter/usercenter')">{{NAME || '游客'}}</text>
					<!-- #endif -->
				</view>
			</view>
			<view class="vip-card-box" >
				<image class="card-bg" src="http://img.nczywc.cn/bg/vip-card-bg.png" mode=""></image>
				<view class="b-btn"  >
				<!-- <view class="b-btn"  @click="testDemo"> -->
				<!-- <view class="b-btn"  @click="navTo('pagesun/yiPin/yiPin')"> -->
					立即升级
				</view>
				<view class="tit">
					<text class="yticon icon-iLinkapp-"></text>
					经纪人
				</view>
				<text class="e-m">经纪人</text>
				<text class="e-b">升级为经纪人  立享多项特权</text>
			</view>
		</view>
		
		<view 
			class="cover-container"
			:style="[{
				transform: coverTransform,
				transition: coverTransition
			}]"
			@touchstart="coverTouchstart"
			@touchmove="coverTouchmove"
			@touchend="coverTouchend"
		>
			<image class="arc" src="/static/arc.png"></image>
			
			<view class="tj-sction">
				<view class="tj-item" @click="navTo('/pages/growup/growup')">
					<text>积分</text>
					<text class="num">{{property.sppoint}}</text>
				</view>
				<view class="tj-item" @click="navTo('/pages/growup/jkpointRecord')">
					<text>抵扣券</text>
					<text class="num">{{property.dedu}}</text>
				</view>
				<view class="tj-item" @click="navToEcoupon">
					<text>惠券</text>
					<text class="num">{{property.coupon}}</text>
				</view>
				
				<view class="tj-item" @click="navTo('/pages/collect/collect')">
					<text>关注</text>
					<text class="num">{{property.collect}}</text>
				</view>
			</view>
			<!-- 订单 -->
			<view class="order-section">
				<view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon  icon-shouye" ></text>
					<text>全部订单</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=1')"  hover-class="common-hover" :hover-stay-time="50">
					<text class="yticon icon-daifukuan"></text>
					<view class="badge1" v-if="daiNum>0">{{daiNum}}</view>
					<text>待付款</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon icon-yishouhuo"></text>
					<view class="badge1" v-if="shouNum>0">{{shouNum}}</view>
					<text>待收货</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=3')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon icon-pingjia"></text>
					<view class="badge1" v-if="commenNum>0">{{commenNum}}</view>
					<text>待评价</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=4')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon icon-fenxiang2"></text>
					<view class="badge1" v-if="shareNum>0">{{shareNum}}</view>
					<text>待分享</text>
				</view>
				<!-- <view class="order-item"  @click="navTo('/pages/order/order?state=4')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon icon-shouhoutuikuan"></text>
					<text>退款/售后</text>
				</view> -->
			</view>
			<!-- 我的收藏 -->
			<!-- <view class="order-section">
				<view class="order-item" @click="navTo('/pages/cart/cart')" hover-class="common-hover"  :hover-stay-time="50">
					<text class="yticon  icon-shoucang"></text>
					<text>我的收藏</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=1')"  hover-class="common-hover" :hover-stay-time="50">
					<text>99</text>
					<text>商品</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover"  :hover-stay-time="50">
					<text >99</text>
					<text>专题</text>
				</view>
				<view class="order-item"  @click="navTo('/pages/order/order?state=3')" hover-class="common-hover"  :hover-stay-time="50">
					<text >99</text>
					<text>话题</text>
				</view>
				<view class="order-item" @click="navTo('/pages/order/order?state=4')" hover-class="common-hover"  :hover-stay-time="50">
					<text>99</text>
					<text>评价</text>
					
				</view>
			</view> -->
			<!-- 浏览历史 -->
			<view class="order-line1" >
				<list-cell icon="iconfont icon-zijin" iconColor="#9D9D9D" title="资金管理"  @eventClick="loginPay"  ></list-cell>
				<list-cell icon="yticon icon-lishijilu" iconColor="#9F9F9F" title="我的足迹"  @eventClick="navTo('/pages/history/history')"  ></list-cell>
				<list-cell icon="yticon icon-comment" iconColor="#9D9D9D" title="我的评价"  @eventClick="navTo('/pages/comment/comment')" ></list-cell>
				<list-cell icon="yticon icon-icon-test" iconColor="#9D9D9D" title="地址管理" @eventClick="navTo('/pages/address/address')"></list-cell>
			</view>
			<view class="order-line1" >
				
				<list-cell icon="yticon icon-iLinkapp-" iconColor="#D3D3D3" title="我的会员" :tips="TAICI" @eventClick="navTo('/pages/member/member')"></list-cell>
				<list-cell icon="yticon icon-iconfontweixin" iconColor="#D3D3D3" title="免单中心" @eventClick="navTo('/pages/order/orderfree')"></list-cell>
				<list-cell icon="yticon icon-bianji" iconColor="#9D9D9D" title="每日签到"  @eventClick="navTo('/pages/qiandao/qiandao')"  ></list-cell>
				<list-cell icon="yticon icon-tuandui" iconColor="#9D9D9D" title="我的团队"  @eventClick="navTo('/pages/myTeam/myTeam')"  ></list-cell>
			</view>
			<view class="order-line1" >
				<!-- #ifdef APP-PLUS -->
				<list-cell icon="yticon icon-icon--" iconColor="#9D9D9D" title="开启直播" @eventClick="showRoom" tips="10"></list-cell>
				<!-- <list-cell icon="yticon icon-icon--" iconColor="#9D9D9D" title="开启直播" @eventClick="navTo('/pagesun/live/live?role=20&roomid='+id+'&roomname='+name)" tips="10"></list-cell> -->
				<list-cell icon="yticon icon-icon--" iconColor="#9D9D9D" title="进入直播" @eventClick="togglePopup('three')" tips="10"></list-cell>
				<!-- #endif -->
				<list-cell icon="yticon icon-fenxiang2" iconColor="#9D9D9D" title="邀请有礼" @eventClick="navTo('/pages/invite/invite?invitedId='+id)" tips="邀请好友赢奖励"></list-cell>
				<list-cell icon="yticon icon-dianhua-copy" iconColor="#9D9D9D" title="服务中心"   @eventClick="navTo('/pagesun/service/service')"></list-cell>
				<list-cell icon="yticon icon-shezhi" iconColor="#9D9D9D" title="系统设置" border="" @eventClick="navTo('/pagesun/set/set')"></list-cell>
			</view>
				<!-- <list-cell icon="yticon icon-pinglun-copy" iconColor="#ee883b" title="晒单" tips="晒单抢红包"></list-cell> -->
				<!-- <list-cell icon="yticon icon-iconfontweixin" iconColor="#e07472" title="我的钱包" tips="您的会员还有3天过期"></list-cell> -->
			<!-- #ifdef MP-WEIXIN -->
			<button open-type="contact" type="default" style="margin-top: 20upx;background-color: #FFFFFF;">联系客服</button>
			<!-- #endif -->	
		</view>
		<uni-popup  :show="type=='four'" type="middle" >
			<form class="form1"  @submit="formSubmit2">
				<!-- 登录form -->
				<view class="login_form">
					<view class="pwd">房间号：{{id}}</view>
					<view class="input">
						<input type="password" name="pwd"  v-model="pwd1"  placeholder="房间密码">
					</view>
				</view>
				<!-- 登录提交 -->
				<button class="submit" type="primary"  formType="submit" >确定</button>
				<view class="yticon icon-fork badge" @click="togglePopup('')"></view>
			</form>
		</uni-popup>
		<uni-popup  :show="type=='three'" type="middle" >
			<form class="form1"  @submit="formSubmit2">
				<!-- 登录form -->
				<view class="login_form">
					<view class="pwd" >请填写信息</view>
					
					<view class="input">
						<input type="text" name="newpwd" :value="newpwd1"   placeholder="请输入房间号">
					</view>
					<view class="input">
						<input type="password" name="pwd"  v-model="pwd1"  placeholder="房间密码">
					</view>
				</view>
				<!-- 登录提交 -->
				<button class="submit" type="primary"  formType="submit" >确定</button>
				<view class="yticon icon-fork badge" @click="togglePopup('')"></view>
			</form>
		</uni-popup>
		<uni-popup  :show="type=='one'" type="middle" >
			<form class="form"  @submit="formSubmit">
				<!-- 登录form -->
				<view class="login_form">
					<view class="pwd">请设置支付密码</view>
					<view class="input">
						<input type="password" name="pwd"  v-model="pwd1" placeholder="登录密码" >
					</view>
					<view class="input">
						<input type="password" name="newpwd"  v-model="newpwd1"  placeholder="支付密码">
					</view>
					<text class="find"  @click="navTo('/pages/find-pwd/findpay-pwd')" >忘记密码？</text>
					<!-- <text class="find"   >忘记密码？</text> -->
				</view>
				<!-- 登录提交 -->
				<button class="submit" type="primary"  formType="submit" >确定</button>
				<view class="yticon icon-fork badge" @click="togglePopup('')"></view>
			</form>
		</uni-popup>
		<uni-popup  :show="type=='two'" type="middle" >
			<form class="form1"  @submit="formSubmit1">
				<!-- 登录form -->
				<view class="login_form">
					<view class="pwd">请输入支付密码</view>
					<view class="input">
						<input type="password" name="newpwd" :value="newpwd1"   placeholder="请输入支付密码">
					</view>
					
					<view class="find" @click="navTo('/pages/find-pwd/findpay-pwd1')">
						<text    >忘记密码？</text>
						<!--<text class="find"   >忘记密码？</text>-->
					</view>
				</view>
				<!-- 登录提交 -->
				<button class="submit" type="primary"  formType="submit" >确定</button>
				<view class="yticon icon-fork badge" @click="togglePopup('')"></view>
			</form>
		</uni-popup>
    </view>  
</template>  

<script>  
import {mapMutations} from 'vuex';
	import uniBadge from '@/components/uni-badge/uni-badge.vue';
	import listCell from '@/components/mix-list-cell';
	import uniPopup from '@/components/uni-popup/uni-popup.vue';
	var  graceChecker = require("../../common/graceChecker.js");
    import {  
        mapState 
    } from 'vuex';  
	let startY = 0, moveY = 0, pageAtTop = true;
    export default {
		components: {
			listCell,
			uniBadge,
			uniPopup
		},
		data(){
			return {
				coverTransform: 'translateY(0px)',
				coverTransition: '0s',
				moving: false,
				property:{dedu:0,coupon:0,sppoint:0,collect:0},
				TAICI:'',
				taici1:'',
				NAME:'',
				type: '',
				pwd1:'',
				newpwd1:'',
				daiNum:0,
				shouNum:0,
				commenNum:0,
				shareNum:0,
				avator:'',
				
				SessionKey: '',
				openId: '',
				nickName: null,
				sex:null,
				province:null,
				city:null,
				country:null,
				avatarUrl: null,
				isCanUse: uni.getStorageSync('isCanUse')||true,//默认为true
				id : 0,
				name:'',
				img1:'',
			}
		},
		onLoad(){
			this.img1 = getApp().globalData.imageAddress+"/bg/user-bg9.png";
			console.log("LLLLLLLLLLLLLL",uni.getStorageSync('userInfo'))
			if(uni.getStorageSync('userInfo')){
				
				this.id = uni.getStorageSync('userInfo').USER.ID;
				this.name = uni.getStorageSync('userInfo').USER.CUSTNAME
				console.log("LLLLLLLLLLLLLL",this.id)
			}
			if(uni.getStorageSync("SIGNATURE")){
				// #ifdef MP-WEIXIN
				this.login1();
				// #endif
				this.loadData();
			}else{
				uni.request({
					url: getApp().globalData.http+'/common/regist', //仅为示例，并非真实接口地址。
					data: {
						BRAND : this.BRAND,
						MODEL : this.MODEL,
						OS : this.OS,
						OSVERSION: this.OSVERSION,
						SCREEN: this.SCREEN,
						RESOLUTION: this.RESOLUTION,
						MIDU: this.MIDU,
						UQID: this.UQID,
						OSID: this.OSID,
						TVERSION: this.TVERSION,
						TYPE: this.TYPE,//A.Android B.iPhone C.iPad
					},
					method:"POST",
					header: {
						'content-type':'application/x-www-form-urlencoded',
					},
					success: (res) => {
						uni.setStorageSync("SIGNATURE",res.data.OBJECT.SIGNATURE);
						// #ifdef MP-WEIXIN
						this.login1();
						// #endif
						this.loadData();
					}
				});
			}
			
			this.imgUrl
			this.requestUrl
			console.log(this.imgUrl)
			console.log(this.requestUrl)
			// uni.startPullDownRefresh();
		},
		onShow() {
			this.loadData();
		},
		onPullDownRefresh() {
			this.loadData()
			setTimeout(function () {
				
				uni.stopPullDownRefresh();
			}, 1000);
		},
		// #ifndef MP
		onNavigationBarButtonTap(e) {
			
			const index = e.index;
			if (index === 0) {
				uni.navigateTo({
					url:'/pagesun/set/set'
				})
			}else if(index === 1){
				// #ifdef APP-PLUS
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				currentWebview.hideTitleNViewButtonRedDot({
					index
				});
				// #endif
				uni.navigateTo({
					url: '/pages/news/newstype'
				})
			}
		},
		
		// #endif
        computed: {
			...mapState(['hasLogin','userInfo']),
		},
        methods: {
			...mapMutations(['login']),
			//测试
			testDemo(){
				this.$http.post("/user/info",{
							SIGNATURE:uni.getStorageSync("SIGNATURE"),
							TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					if(res.data.STATE==='0' && res.statusCode===200){
						if(res.data.OBJECT.ID==5){
							uni.navigateTo({
								url:'/pagesun/whoLook/whoLook'
							})
						}
					}
				}).catch(err=>{
							console.log('request fail',err);
				})
			},
			showRoom(){
				if(!this.hasLogin){
					// #ifdef MP-WEIXIN
					uni.showToast({
						title:"请登录",
						icon:"none"
					});
					// #endif
					// #ifndef MP-WEIXIN
					uni.redirectTo({
						url: '/pages/public/login1'
					})
					
					// #endif
				}else {
					this.type = 'four'
				}
			},
			// #ifdef MP-WEIXIN
			
			
			//微信授权第一授权获取用户信息===》按钮触发
			wxGetUserInfo() {
				uni.showLoading({
					mask:true,
					title:'登录中···'
				})
				let _this = this;
				uni.getUserInfo({
					provider: 'weixin',
					success: function(infoRes) {
						_this.nickName = infoRes.userInfo.nickName; //昵称
						_this.sex = infoRes.userInfo.gender;
						_this.province = infoRes.userInfo.province;
						_this.city = infoRes.userInfo.city;
						_this.country = infoRes.userInfo.country;
						_this.avatarUrl = infoRes.userInfo.avatarUrl; //头像
						try {
							uni.setStorageSync('isCanUse', false);//记录是否第一次授权  false:表示不是第一次授权
							_this.updateUserInfo();
							
						} catch (e) {
							console.log(e)
						}
					},
					fail(res) {}
				});
			},
			//微信登录
						login1() {
							let _this = this;
							
							uni.showLoading({
								title: '加载中...'
							});
						 
						   // 1.wx获取登录用户code
							uni.login({
								provider: 'weixin',
								success: function(loginRes) {
									let code = loginRes.code;
									if (!_this.isCanUse) {
										//非第一次授权获取用户信息
										uni.getUserInfo({
											provider: 'weixin',
											success: function(infoRes) {
			 　　　　　　　　　　　　　　　　　　　　　　//获取用户信息后向调用信息更新方法
												_this.nickName = infoRes.userInfo.nickName; //昵称
												_this.sex = infoRes.userInfo.gender;
												_this.province = infoRes.userInfo.province;
												_this.city = infoRes.userInfo.city;
												_this.country = infoRes.userInfo.country;
												_this.avatarUrl = infoRes.userInfo.avatarUrl; //头像
												
												_this.updateUserInfo();//调用更新信息方法
											}
										});
									}
									
									//2.将用户登录code传递到后台置换用户SessionKey、OpenId等信息
									_this.$http.post("/user/wxOpenId",{
										SIGNATURE : uni.getStorageSync("SIGNATURE"),
										CODE: code,
									}).then((e)=>{
										if(e.statusCode == 200 && e.data.STATE== '0'){
											uni.setStorageSync("OPENID",e.data.OBJECT.OPENID)
											uni.hideLoading();
										}
									}).catch((err)=>{
										console.log("请求超时",err);
									})
								},
							});
						},
					 //向后台更新信息
						updateUserInfo() {
							let _this = this;
							_this.$http.post("/user/updateUserInfoWx",{
								SIGNATURE : uni.getStorageSync("SIGNATURE"),
								OPENID:uni.getStorageSync("OPENID"),
								NICKNAME: _this.nickName,
								SEX:_this.sex,
								PROVINCE:_this.province,
								CITY:_this.city,
								COUNTRY:_this.country,
								HEADIMGURL: _this.avatarUrl,
							}).then((e)=>{
								if(e.statusCode == 200 && e.data.STATE== '0'){
									console.log("更新用户信息成功,并且登录成功",)
									_this.login(e.data.OBJECT);
									uni.hideLoading()
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/index/index'
									});
								}else if(e.statusCode == 200 && e.data.STATE== '-1'&&e.data.MSG=='未找到OPENID'){
									this.login1()
								}else if(e.statusCode == 200 && e.data.STATE== '-1'){
									console.log("跳转注册")
									uni.hideLoading()
									uni.navigateTo({
										url: '/pages/public/wechatLogin/regWx'
									});
								}
							}).catch((err)=>{
								console.log("请求超时",err);
							})
						},
			// #endif
			
			navToEcoupon(){
				this.$http.post("/user/info",{
							SIGNATURE:uni.getStorageSync("SIGNATURE"),
							TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					if(res.data.STATE == '903'||res.data.STATE == '904'){
						// #ifdef MP-WEIXIN
						uni.showToast({
							title:"请登录",
							icon:"none"
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.navigateTo({
							url : '/pages/public/login1'
						})
						// #endif
					}else if(res.data.STATE==='0' && res.statusCode===200){
						this.togglePopup('')
						
							uni.navigateTo({
								url:'/pages/ecoupon/ecoupon'
							})
						
					}else if(res.data.STATE === "907" && res.statusCode === 200){
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '请重新登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}
							},
						})
					}else if(res.data.STATE === "906" && res.statusCode === 200){
						//正常退出失效
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						// #ifdef MP-WEIXIN
						uni.reLaunch({//信息更新成功后跳转到小程序首页
							url: '/pages/user/user'
						});
						// #endif
						// #ifndef MP-WEIXIN
						uni.reLaunch({
							url : '/pages/public/login1'
						})
						// #endif
						
					}else if(res.data.STATE === "905" && res.statusCode === 200){
						//别处登录失效
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '已在别处登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}
							},
						})
					}
				}).catch(err=>{
							console.log('request fail',err);
				})
				
				
			},
			
							/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			
			navTo(url){
				
				if(!this.hasLogin){
					// #ifdef MP-WEIXIN
					uni.showToast({
						title:"请登录",
						icon:"none"
					})
					// #endif
					// #ifndef MP-WEIXIN
					url = '/pages/public/login1';
					// #endif
				}
				
				this.$http.post("/user/info",{
					SIGNATURE:uni.getStorageSync("SIGNATURE"),
					TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					if(res.data.STATE == '903'||res.data.STATE == '904'){
						// #ifdef MP-WEIXIN
						uni.showToast({
							title:"请登录",
							icon:"none"
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.navigateTo({
						 url:'/pages/public/login1'
						})
						// #endif
						
					}else if(res.data.STATE==='0' && res.statusCode===200){
						
						this.togglePopup('')
						uni.navigateTo({
							url,
						})  
					}else if(res.data.STATE === "907" && res.statusCode === 200){
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '请重新登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									
								}
							},
						})
					}else if(res.data.STATE === "906" && res.statusCode === 200){
						//正常退出失效
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						// #ifdef MP-WEIXIN
						uni.showToast({
							title:"请登录",
							icon:"none"
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.reLaunch({
						 url:'/pages/public/login1'
						})
						// #endif
						
					}else if(res.data.STATE === "905" && res.statusCode === 200){
						//别处登录失效
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '已在别处登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
									 url:'/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
									 url:'/pages/public/login1'
									})
									// #endif
								}
							},
						})
					}
				}).catch(err=>{
							console.log('request fail',err);
				})
				
			}, 
			togglePopup(type){
				if(type===''){
					this.pwd1 = ''
					this.newpwd1 = ''
				}
				this.type = type
			},
			loginPay(){
				if(!this.hasLogin){
					// #ifdef MP-WEIXIN
					uni.showToast({
						title:"请登录",
						icon:"none"
					})
					// #endif
					// #ifndef MP-WEIXIN
					uni.navigateTo({
						url : '/pages/public/login1'
					})
					// #endif
					
				}
				//是否需要强制修改支付密码
				this.$http.post('/user/findFirst',{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					TOKEN: uni.getStorageSync("userInfo").TOKEN,
				}).then((res)=>{
					//判断返回内容
					if(res.data.STATE === "0" && res.statusCode === 200){
						if(res.data.OBJECT == 0){
							this.type = 'one'
						}else if(res.data.OBJECT == 1){
							//登录
							this.type = 'two'
							// navTo('/pages/money/money')
						}
					}else if(res.data.STATE == '903'||res.data.STATE == '904'){
						// #ifdef MP-WEIXIN
						uni.showToast({
							title:"请登录",
							icon:"none"
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.navigateTo({
						 url:'/pages/public/login1'
						})
						// #endif
						
					}else if(res.data.STATE === "907" && res.statusCode === 200){
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '请重新登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
										url : '/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									
								}
							},
						})
					}else if(res.data.STATE === "906" && res.statusCode === 200){
						//正常退出失效
						//token已经失效  重新登录
						uni.removeStorageSync('userInfo')
						// #ifdef MP-WEIXIN
						uni.showToast({
							title:"请登录",
							icon:"none"
						})
						// #endif
						// #ifndef MP-WEIXIN
						uni.reLaunch({
						 url:'/pages/public/login1'
						})
						// #endif
						
					}else if(res.data.STATE === "905" && res.statusCode === 200){
						//别处登录失效
						uni.removeStorageSync('userInfo')
						uni.showModal({
							content: '已在别处登录',
							success: (res)=>{
								if(res.confirm){
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
									 url:'/pages/public/login1'
									})
									// #endif
								}else if(res.cancel) {
									// #ifdef MP-WEIXIN
									uni.reLaunch({//信息更新成功后跳转到小程序首页
										url: '/pages/user/user'
									});
									// #endif
									// #ifndef MP-WEIXIN
									uni.reLaunch({
									 url:'/pages/public/login1'
									})
									// #endif
								}
							},
						})
					}
				})
				.catch((err)=>{
				    console.log('request fail', err);
				})
			},
			sleep1(numberMillis) { 
				var now = new Date(); 
				var exitTime = now.getTime() + numberMillis; 
				console.log("6666666666666")
				while (true) { 
					now = new Date(); 
					if (now.getTime() > exitTime) {
						return; 
					}
				} 
			},
			formSubmit2(e){
				var rule = [
					 {name:"pwd", checkType: "int", checkRule: "5,6", errorMsg: "请输入6位数字" },
				];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = graceChecker.check(formData, rule);
				if(checkRes){
					var IDS ;
					if (this.type == 'three'){
						IDS = e.detail.value.newpwd;
					} else {
						IDS = 0;
					}
					//进入直播间
					this.$http.post('/user/goRoom',{
						SIGNATURE : uni.getStorageSync("SIGNATURE"),
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
						PWD:e.detail.value.pwd,
						ID:IDS
					}).then((res)=>{
						//判断返回内容
						if(res.data.STATE === "0" && res.statusCode === 200){
							if (this.type == 'three'){
								this.togglePopup('')
								uni.navigateTo({
									url: '/pagesun/live/live?role=21&roomid='+e.detail.value.newpwd
								})
							}else {
								this.togglePopup('')
								uni.navigateTo({
									url: '/pagesun/live/live?role=20&roomid='+this.id+'&roomname='+this.name
								})
							}
						}else{
							if(res.data.MSG != ''){
								uni.showToast({
									title: res.data.MSG,
									icon: "none",
								})
							}
						}
					})
					.catch((err)=>{
						console.log('request fail', err);
					})
				
				}else{
					uni.showToast({ title: graceChecker.error, icon: "none" });
				}
			},
			formSubmit(e){
				var rule = [
				];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = graceChecker.check(formData, rule);
				if(checkRes){
					//首次强制修改密码
					this.$http.post('/user/setPayPWD',{
						SIGNATURE : uni.getStorageSync("SIGNATURE"),
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
						PWD:e.detail.value.pwd,
						NEWPWD:e.detail.value.newpwd,
						// PAYTOKEN:uni.getStorageSync("userInfo").TOKENP,
						// ISFIRST: 1
					}).then((res)=>{
						//判断返回内容
						if(res.data.STATE === "0" && res.statusCode === 200){
							this.sleep1(2000);
							this.$http.post('/user/loginPay',{
								SIGNATURE : uni.getStorageSync("SIGNATURE"),
								TOKEN: uni.getStorageSync("userInfo").TOKEN,
								PWD:e.detail.value.newpwd,
							}).then((res1)=>{
								//判断返回内容
								if(res1.data.STATE === "0" && res1.statusCode === 200){
									// let userInfo = uni.getStorageSync("userInfo")
									// userInfo.TOKENP = res1.data.OBJECT
									// uni.setStorageSync("userInfo",userInfo)
									this.togglePopup('')
									uni.navigateTo({
										url:'/pages/money/money'
									})
								}
							})
							.catch((err1)=>{
							    console.log('request fail', err1);
							})
						}else if((res.statusCode === 200) && (res.data.STATE === '-1')){
							if(res.data.MSG.length>10){
								if(res.data.MSG.split("]")[1].split("[")[0] === '登录凭证已失效，请重新登录'){
									uni.showLoading({
										title: '网络错误，请重新登录'
									})
									setTimeout(function () {
										uni.removeStorageSync('userInfo')
										uni.hideLoading()
										// #ifdef MP-WEIXIN
										uni.showToast({
											title:"请点击登录",
											icon:"none"
										})
										// #endif
										// #ifndef MP-WEIXIN
										uni.reLaunch({
											url : '/pages/public/login1'
										})
										// #endif
									}, 1000);
									
								}
							}else{
								if(res.data.MSG != ''){
									uni.showToast({
										title: res.data.MSG,
										icon: "none",
									})
								}
							}
						}else{
							if(res.data.MSG != ''){
								uni.showToast({
									title: res.data.MSG,
									icon: "none",
								})
							}
						}
					})
					.catch((err)=>{
					    console.log('request fail', err);
					})
					
					
				}else{
					uni.showToast({ title: graceChecker.error+'3', icon: "none" });
				}
			},
			
			//如果已经重置过支付密码 则进行登录
			formSubmit1(e){
				var rule = [
				];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = graceChecker.check(formData, rule);
				if(checkRes){
					this.$http.post('/user/loginPay',{
						SIGNATURE : uni.getStorageSync("SIGNATURE"),
						TOKEN: uni.getStorageSync("userInfo").TOKEN,
						PWD:e.detail.value.newpwd,
					}).then((res1)=>{
						//判断返回内容
						if(res1.data.STATE === "0" && res1.statusCode === 200){
							
							// let userInfo = uni.getStorageSync("userInfo")
							// userInfo.TOKENP = res1.data.OBJECT
							// uni.setStorageSync("userInfo",userInfo)
							this.togglePopup('')
							uni.navigateTo({
								url:'/pages/money/money'
							})
						}else{
							
							if(res1.data.MSG != ''){
								uni.showToast({
									title: res1.data.MSG,
									icon: "none",
								})
							}
						}
					})
					.catch((err1)=>{
						console.log('request fail', err1);
					})
				}else{
					uni.showToast({ title: graceChecker.error+'2', icon: "none" });
				}
			},
			async loadData(){
				//用户基本信息
				this.$http.post("/user/info",{
							SIGNATURE:uni.getStorageSync("SIGNATURE"),
							TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					if(res.data.STATE==='0' && res.statusCode===200){
						 const user=res.data.OBJECT;
						  if(user && user.TAICI===1){
							this.TAICI='普通会员'
						  }else if(user &&user.TAICI===2){
							this.TAICI='黄金会员'
						  }else if(user &&user.TAICI===3){
							this.TAICI='铂金会员'
						  }else if(user &&user.TAICI===4){
							this.TAICI='经纪人'
						  }else if(user &&user.TAICI===5){
							this.TAICI='营业部'
						  }else if(user &&user.TAICI===6){
							this.TAICI='分公司'
						  }else if(user &&user.TAICI===7){
							this.TAICI='公司'
						  }
						  if (user) {
							this.taici1=user.TAICI;
							this.NAME=user.NAME;
							this.property.sppoint=user.SPPOINT;
							this.property.dedu=user.JKPOINT;
							this.property.coupon=user.JYPOINT;
							if(user.AVATOR){
								this.avator=getApp().globalData.imageAddress+user.AVATOR;
							}
						  }
						
					}else{
						this.NAME=''
					}
				}).catch(err=>{
							console.log('request fail',err);
				})
				//获取收藏数
				this.$http.post("/user/property",{
					SIGNATURE:uni.getStorageSync("SIGNATURE"),
					TOKEN:uni.getStorageSync('userInfo').TOKEN,
				}).then(res=>{
					if(res.data.STATE==='0' && res.statusCode===200){
						this.property.collect=res.data.OBJECT.COLLECTIONNUM;
					}
				}).catch(err=>{
					console.log('request fail',err);
				})
				//获取订单数量显示角标
				this.$http.post("/order/findOrderNum",{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					TOKEN: uni.getStorageSync('userInfo').TOKEN,
				}).then(e=>{
					if(e.data.STATE === '0' && e.statusCode === 200){
						this.daiNum=0,
						this.shouNum=0,
						this.commenNum=0,
						e.data.OBJECT.map(item=>{
							if(item.ORDERSTATE==1){
								this.daiNum=this.daiNum+item.NUM;
							}
							if(item.ORDERSTATE==2){
								this.shouNum=this.shouNum+item.NUM;
							}
							if(item.ORDERSTATE==6){
								this.shouNum=this.shouNum+item.NUM;
							}
							if(item.ORDERSTATE==3){
								this.commenNum=this.commenNum+item.NUM;
							}
						})
					}
				}).catch(err =>{
					console.log('request fail', err);
				}),
				
				//获取团购订单待分享数量显示角标
				this.$http.post("/order/findOrderNumShare",{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					TOKEN: uni.getStorageSync('userInfo').TOKEN,
				}).then(e=>{
					if(e.data.STATE === '0' && e.statusCode === 200){
						this.shareNum=e.data.OBJECT.NUM
					}
				}).catch(err =>{
					console.log('request fail', err);
				})
				
			}, 
			
				
			/**
			 *  会员卡下拉和回弹
			 *  1.关闭bounce避免ios端下拉冲突
			 *  2.由于touchmove事件的缺陷（以前做小程序就遇到，比如20跳到40，h5反而好很多），下拉的时候会有掉帧的感觉
			 *    transition设置0.1秒延迟，让css来过渡这段空窗期
			 *  3.回弹效果可修改曲线值来调整效果，推荐一个好用的bezier生成工具 http://cubic-bezier.com/
			 */
			coverTouchstart(e){
				if(pageAtTop === false){
					return;
				}
				this.coverTransition = 'transform .1s linear';
				startY = e.touches[0].clientY;
			},
			coverTouchmove(e){
				moveY = e.touches[0].clientY;
				let moveDistance = moveY - startY;
				if(moveDistance < 0){
					this.moving = false;
					return;
				}
				this.moving = true;
				if(moveDistance >= 80 && moveDistance < 100){
					moveDistance = 80;
				}
		
				if(moveDistance > 0 && moveDistance <= 80){
					this.coverTransform = `translateY(${moveDistance}px)`;
				}
			},
			coverTouchend(){
				if(this.moving === false){
					return;
				}
				this.moving = false;
				this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
				this.coverTransform = 'translateY(0px)';
			}
        }  
    }  
</script>  
<style lang='scss'>
	%flex-center {
	 display:flex;
	 flex-direction: column;
	 justify-content: center;
	 align-items: center;
	}
	%section {
	  display:flex;
	  justify-content: space-around;
	  align-content: center;
	  background: #fff;
	  border-radius: 10upx;
	}
	.form{
		background-color: #f5f5f5;
		width: 450upx;
		height: 460upx;
		border-radius: 8%;
		border: 2upx solid #9F9F9F;
		.login_form{
			margin: 20upx;
			padding-left: 30upx;
			padding-right: 30upx;
			.pwd{
				font-size: 35upx;
				font-weight: 900;
				text-align: center;
			}
			.input{
				border: 1upx solid #9F9F9F;
				margin: 40upx 0upx 20upx 0upx;
				height: 60upx;
			}
			
		}
		.submit{
			background-color: #E02E24;
			width: 80%;
		}
		.yticon{
			position: absolute;
			top: 30upx;
			left: 400upx;
			color: #EBEDF0;
			background-color: #999999;
			border-radius: 100%;
		}
	}
	.find{
		font-size: 30upx;
		color: #FA436A;
		margin: 10upx 0upx;
		padding: 10upx 0upx;
		text-align: right;
	}
	.form1{
		background-color: #f5f5f5;
		width: 550upx;
		height: 400upx;
		border-radius: 5%;
		padding: 10upx 0upx;
		border: 2upx solid #9F9F9F;
		.login_form{
			margin: 20upx;
			padding-left: 30upx;
			padding-right: 30upx;
			.pwd{
				font-size: 35upx;
				font-weight: 900;
				text-align: center;
			}
			.input{
				border: 1upx solid #9F9F9F;
				margin: 40upx 0upx 0upx 0upx;
				height: 60upx;
			}
		}
		.submit{
			background-color: #E02E24;
			width: 80%;
		}
		.yticon{
			position: absolute;
			top: 40upx;
			left: 480upx;
			color: #EBEDF0;
			background-color: #999999;
			border-radius: 100%;
		}
	}
	
	.user-section{
		height: 520upx;
		padding: 100upx 30upx 0;
		position:relative;
		.bg{
			position:absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 100%;
		}
	}
	.user-info-box{
		height: 180upx;
		display:flex;
		align-items:center;
		position:relative;
		z-index: 1;
		.portrait{
			width: 130upx;
			height: 130upx;
			border:5upx solid #fff;
			border-radius: 50%;
		}
		.username{
			font-size: $font-lg + 18upx;
			color: $font-color-dark;
			margin-left: 20upx;
		}
	}

	.vip-card-box{
		display:flex;
		flex-direction: column;
		color: #f7d680;
		height: 240upx;
		background: linear-gradient(left, rgba(0,0,0,1.0), rgba(0,0,0,.8));
		border-radius: 16upx 16upx 0 0;
		overflow: hidden;
		position: relative;
		padding: 20upx 24upx;
		.card-bg{
			position:absolute;
			top: 20upx;
			right: 0;
			width: 380upx;
			height: 260upx;
		}
		.b-btn{
			position: absolute;
			right: 20upx;
			top: 16upx;
			width: 132upx;
			height: 40upx;
			text-align: center;
			line-height: 40upx;
			font-size: 22upx;
			color: #36343c;
			border-radius: 20px;
			background: linear-gradient(left, #f9e6af, #ffd465);
			z-index: 1;
		}
		.tit{
			font-size: $font-base+4upx;
			color: #f7d680;
			margin-bottom: 28upx;
			.yticon{
				color: #f6e5a3;
				margin-right: 20upx;
			}
		}
		.e-b{
			font-size: $font-sm;
			color: #d8cba9;
			margin-top: 10upx;
		}
	}
	.cover-container{
		background: $page-color-base;
		margin-top: -150upx;
		padding: 0 30upx;
		position:relative;
		background: #f5f5f5;
		padding-bottom: 20upx;
		.arc{
			position:absolute;
			left: 0;
			top: -34upx;
			width: 100%;
			height: 36upx;
		}
	}
	.order-line1{
		color: rgb(153, 153, 153); 
		background-color: #fff;
		margin-top: 20upx;
	}
	.tj-sction{
		@extend %section;
		.tj-item{
			@extend %flex-center;
			flex-direction: column;
			height: 140upx;
			font-size: $font-sm;
			color: rgb(153, 153, 153);
			font-family: "微软雅黑"; 
			font-weight: 400;
			
		}
		.num{
			font-size: $font-lg;
			color: $font-color-num;
			margin-bottom: 8upx;
			font-family: "Georgia Negreta", "Georgia"; 
			font-weight: 700;
		}
	}
	.order-section{
		@extend %section;
		padding: 28upx 0;
		margin-top: 20upx;
		.order-item{
			position: relative;
			@extend %flex-center;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: $font-sm;
			color: $font-color-dark;
			//消息提示角标
			.badge{
				position:absolute;
				width:4vw;
				height:4vw;
				background-color:#ec6d2c;
				top:25vw;
				right:82vw;
				border-radius:100%;
				font-size:20upx;color:#fff;
				display:flex;
				align-items: center;
				justify-content: center;
				z-index: 10;
			}
			.badge1{
				position:absolute;
				width:4vw;
				height:4vw;
				background-color:#E02E24;
				top:0upx;
				right:5upx;
				border-radius:100%;
				font-size:20upx;color:#fff;
				display:flex;
				justify-content: center;
				z-index: 10;
				line-height: 4vw;
			}
		}
		
		.yticon{
			font-size: 48upx;
			margin-bottom: 18upx;
			/* color: #FFAF60; */
			color: #9F9F9F;
			
		}
		.icon-shouhoutuikuan{
			font-size:44upx;
		}
	}
	.history-section{
		padding: 30upx 0 0;
		margin-top: 20upx;
		background: #fff;
		border-radius:10upx;
		.sec-header{
			display:flex;
			align-items: center;
			font-size: $font-base;
			color: $font-color-dark;
			line-height: 40upx;
			margin-left: 30upx;
			.yticon{
				font-size: 44upx;
				color: #E02E24;
				margin-right: 16upx;
				line-height: 40upx;
			}
		}
		.h-list{
			white-space: nowrap;
			padding: 30upx 30upx 0;
			image{
				display:inline-block;
				width: 160upx;
				height: 160upx;
				margin-right: 20upx;
				border-radius: 10upx;
			}
		}
	}
	button::after{ border: none;} 
</style>